from hera.workflows import Container, Step, Steps, Workflow
from hera.workflows.models import Arguments, Inputs, IntOrString, Parameter, Sequence

with Workflow(
    arguments=Arguments(
        parameters=[
            Parameter(
                name="count",
                value="3",
            )
        ],
    ),
    api_version="argoproj.io/v1alpha1",
    kind="Workflow",
    generate_name="loops-sequence-",
    entrypoint="loops-sequence",
) as w:
    with Steps(
        name="loops-sequence",
    ) as invocator:
        with invocator.parallel():
            Step(
                arguments=Arguments(
                    parameters=[
                        Parameter(
                            name="msg",
                            value="{{item}}",
                        )
                    ],
                ),
                name="sequence-count",
                template="echo",
                with_sequence=Sequence(
                    count=IntOrString(
                        __root__="5",
                    ),
                ),
            )
            Step(
                arguments=Arguments(
                    parameters=[
                        Parameter(
                            name="msg",
                            value="{{item}}",
                        )
                    ],
                ),
                name="sequence-start-end",
                template="echo",
                with_sequence=Sequence(
                    end=IntOrString(
                        __root__="105",
                    ),
                    start=IntOrString(
                        __root__="100",
                    ),
                ),
            )
            Step(
                arguments=Arguments(
                    parameters=[
                        Parameter(
                            name="msg",
                            value="{{item}}",
                        )
                    ],
                ),
                name="sequence-param",
                template="echo",
                with_sequence=Sequence(
                    count=IntOrString(
                        __root__="{{workflow.parameters.count}}",
                    ),
                    start=IntOrString(
                        __root__="200",
                    ),
                ),
            )
            Step(
                arguments=Arguments(
                    parameters=[
                        Parameter(
                            name="msg",
                            value="{{item}}",
                        )
                    ],
                ),
                name="sequence-negative",
                template="echo",
                with_sequence=Sequence(
                    end=IntOrString(
                        __root__="0",
                    ),
                    start=IntOrString(
                        __root__="5",
                    ),
                ),
            )
            Step(
                arguments=Arguments(
                    parameters=[
                        Parameter(
                            name="msg",
                            value="{{item}}",
                        )
                    ],
                ),
                name="sequence-format",
                template="echo",
                with_sequence=Sequence(
                    count=IntOrString(
                        __root__="5",
                    ),
                    format="testuser%02X",
                ),
            )
    Container(
        inputs=Inputs(
            parameters=[
                Parameter(
                    name="msg",
                )
            ],
        ),
        name="echo",
        command=["echo", "{{inputs.parameters.msg}}"],
        image="alpine:latest",
    )
